<template>
  <v-chart class="chart" :option="option" />
</template>
<script>
import VChart from "vue-echarts"
// import axios from "axios";

export default {
  name: "Echarts_bar",
  components: {
    VChart
  },
  data() {
    return {
      option: {
        title: {
          text: 'Referer of a Website',
          subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'right'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 1048, name: 'Search Engine' },
              { value: 735, name: 'Direct' },
              { value: 580, name: 'Email' },
              { value: 484, name: 'Union Ads' },
              { value: 300, name: 'Video Ads' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
    }
  },
  mounted() {
    // axios.post("/statistics", { keyword: "甲状腺" }, {
    //   headers: {
    //     'Content-Type': 'application/json',
    //     'Cookie': 'iz5xi3tnlimvsmjdaabl5ln0wabnwc9w',
    //   }
    // }).then((res) => {
    //   this.option.series[0].data = res.data;
    // })
  },
  method: {
    getCookie() {
      let temp = {}
      if (document.cookie !== '') {
        document.cookie.split('; ').forEach(item => {
          temp[item.split('=')[0]] = item.split('=')[1]
        })
      }
      return temp.sessionid;
    },
  }
}
</script>

<style scoped>
.chart {
  width: 600px;
  height: 400px;
}
</style>
